#include <cstdio>

int a[1000][1000] = {0};

int main()
{
	freopen("max.in", "r", stdin);
	freopen("max.out", "w", stdout);
	
	int n = 0, m = 0;
	scanf("%d %d", &n, &m);
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < m; j++ ) {
			scanf("%d", &a[i][j]);
		}
	}
	
	long long t = 0;
	for ( int i = 0; i < n; i++ )
	{
		int max = a[i][0];
		for ( int j = 1; j < m; j++ ) {
			if ( max < a[i][j] ) {
				max = a[i][j];
			}
		}
		t += max;
	}
	printf("%lld", t);
	fclose(stdin);
	fclose(stdout);
	return 0;
} 
